﻿// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

namespace Coding4Fun.Chair.Robot
{
    public struct Speed
    {
        public double LeftMotorFront { get; set; }
        public double LeftMotorBack { get; set; }

        public double RightMotorFront { get; set; }
        public double RightMotorBack { get; set; }

        public static bool operator ==(Speed first, Speed second)
        {
            return first.Equals(second);
        }

        public static bool operator !=(Speed first, Speed second)
        {
            return !first.Equals(second);
        }

        public bool Equals(Speed other)
        {
            return other.LeftMotorFront.Equals(LeftMotorFront) && other.LeftMotorBack.Equals(LeftMotorBack) && other.RightMotorFront.Equals(RightMotorFront) && other.RightMotorBack.Equals(RightMotorBack);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (obj.GetType() != typeof (Speed)) return false;
            return Equals((Speed) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = LeftMotorFront.GetHashCode();
                result = (result*397) ^ LeftMotorBack.GetHashCode();
                result = (result*397) ^ RightMotorFront.GetHashCode();
                result = (result*397) ^ RightMotorBack.GetHashCode();
                return result;
            }
        }
    }
}
